<?php
/**
 * Created by PhpStorm.
 * Author: daly
 * Date: 2020/9/22
 * Time: 13:32
 * TEL : 18665585707  Weacht:awngxiaogang
 * luck: 520
 */

namespace app\wap\controller;




use app\admin\model\Store;
use app\wap\model\member\Users;
use think\App;
use think\facade\Cache;
use think\facade\Log;
use think\facade\View;

class Base
{

    protected $client;

    protected $redis;

    /**
     * 构造方法
     * @access public
     * @param  App  $app  应用对象
     */
    public function __construct()
    {

        // $params = array(
        //     '127.0.0.1:9200'
        // );
        // $this->client = ClientBuilder::create()->setHosts($params)->build();

       // $this->redis=Cache::store('redis');
        $this->initialize();
    }

    protected $store_info=[];

    /**
     * 初始化操作
     */
    public function initialize()
    {
        header("Content-type: text/html; charset=utf-8");
        header('Access-Control-Allow-Origin:*');
        error_reporting(0);
        define('Q_URL',config('tag.SITE_URL'));  // 当前模块名称是
        define('PHOTO_URL',config('tag.SITE_URL')); // 本地七牛图片地址halt(Request()->cookie());
        $token=Request()->header('TOKEN');
        $check=array(
            'register','login', 'send','buildMobile','Logout','endbackUploads','GoodsList','GoodsDetail','UploadExcel','FullSearch','GetGroupGoods','uploadImg','GetShareType'
        );
//        if (!in_array(request()->action(), $check)) {
//
//            $uid= Users::GetUid($token);
//           if(empty($token)){
//                exit(json_encode(['code'=>5000001,'msg'=>'token不存在']));
//            }
//            $Cache_token=Cache::store('redis')->get('token_'.$uid);
//            if ($Cache_token !=$token) {
//                Log::record('【token是】'.$Cache_token.'操作方法【'.request()->action().'】日期：'.date('Y-m-d H:i:s'));
//                exit(json_encode(['code'=>5000001,'msg'=>'token已经过期']));
//            }
//        }
        !empty($token) ? $uid=Users::GetUid($token):$uid=0;

        $this->store_info=Store::where(['id'=>2])->find();


        View::assign('store_info',$this->store_info);

        define('SID',2);//门店id
        define('UID',$uid);//用户UID
    }



}